package com.justdoit.facedemo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.justdoit.facedemo.domain.Meeting;
import com.justdoit.facedemo.domain.MeetingVo;
import com.justdoit.facedemo.domain.PunchCard;
import com.justdoit.facedemo.domain.PunchCardVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PunchCardMapper extends BaseMapper<PunchCard> {
    //查询所有的会议
    @Select(" select\n" +
            "u.user_id,m.meeting_id,p.punch_id,u.user_name,m.conference_theme,p.state,p.time,p.method,p.remark\n" +
            "from punch_card as p\n" +
            "left join user_table as u\n" +
            "on p.user_id = u.user_id\n" +
            "left join\n" +
            "meeting_minutes as m\n" +
            "on p.meeting_id = m.meeting_id \n" +
            "where u.user_name like #{user_name} and p.state like #{state}\n" +
            "limit #{pageNum},#{pageSize}")
    public List<PunchCardVo> selectCard(@Param("user_name") String user_name,
                                              @Param("state") String state,
                                              @Param("pageNum")Integer pageNum,
                                              @Param("pageSize")Integer pageSize );

    //查询总数量
    @Select("select count(*) \n" +
            "from punch_card as p\n" +
            "left join user_table as u\n" +
            "on p.user_id = u.user_id\n" +
            "left join\n" +
            "meeting_minutes as m\n" +
            "on p.meeting_id = m.meeting_id \n" +
            "where u.user_name like #{user_name} and p.state like #{state}")
    public Integer selectTotal(@Param("user_name") String user_name,
                               @Param("state") String state);

}
